home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KDChartTextPiece.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  3.3 KB  |  102 lines

  1. /* -*- Mode: C++ -*-
  2.    KDChart - a multi-platform charting engine
  3.    */
  4.  
  5. /****************************************************************************
  6.  ** Copyright (C) 2001-2003 Klar├ñlvdalens Datakonsult AB.  All rights reserved.
  7.  **
  8.  ** This file is part of the KDChart library.
  9.  **
  10.  ** This file may be distributed and/or modified under the terms of the
  11.  ** GNU General Public License version 2 as published by the Free Software
  12.  ** Foundation and appearing in the file LICENSE.GPL included in the
  13.  ** packaging of this file.
  14.  **
  15.  ** Licensees holding valid commercial KDChart licenses may use this file in
  16.  ** accordance with the KDChart Commercial License Agreement provided with
  17.  ** the Software.
  18.  **
  19.  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20.  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21.  **
  22.  ** See http://www.klaralvdalens-datakonsult.se/?page=products for
  23.  **   information about KDChart Commercial License Agreements.
  24.  **
  25.  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
  26.  ** licensing are not clear to you.
  27.  **
  28.  **********************************************************************/
  29. #ifndef __KDCHARTTEXTPIECE_H__
  30. #define __KDCHARTTEXTPIECE_H__
  31.  
  32. #include <qstring.h>
  33. #include <qfont.h>
  34. #include <qregion.h>
  35. #include <qpalette.h>
  36. #include <qobject.h>
  37. #include <kdchart_export.h>
  38.  
  39. class QBrush;
  40. class QPainter;
  41. class QSimpleRichText;
  42. class QFontMetrics;
  43.  
  44. class KDCHART_EXPORT KDChartTextPiece :public QObject
  45. {
  46.     Q_OBJECT
  47.  
  48.     public:
  49.         KDChartTextPiece();
  50.         KDChartTextPiece( const QString& text, const QFont& font );
  51.         KDChartTextPiece( QPainter* painter, const QString& text, const QFont& font );
  52.         virtual ~KDChartTextPiece();
  53.         /**
  54.           Copy the settings of text piece \c source into this box.
  55.  
  56.           \note Use this method instead of using the assignment operator.
  57.  
  58.           \sa clone
  59.           */
  60.         void deepCopy( const KDChartTextPiece* source );
  61.  
  62.  
  63.         /**
  64.           Create a new text piece on the heap, copy the settings stored by
  65.           this text piece into the newly created text piece and return
  66.           the pointer to the new text piece.
  67.  
  68.           \note Use this method instead of using the copy constructor.
  69.  
  70.           \sa deepCopy
  71.           */
  72.         const KDChartTextPiece* clone() const;
  73.  
  74.     private:
  75.         KDChartTextPiece( const KDChartTextPiece& ) : QObject(0) {}
  76.  
  77.     public slots:
  78.         virtual int width() const;
  79.         virtual int height() const;
  80.         virtual int fontLeading() const;
  81.         virtual QRect rect( QPainter *p, const QRect& clipRect) const;
  82.         virtual void draw( QPainter *p, int x, int y, const QRect& clipRect,
  83.                 const QColor& color, const QBrush* paper = 0 ) const;
  84.         virtual void draw( QPainter *p, int x, int y, const QRegion& clipRegion,
  85.                 const QColor& color, const QBrush* paper = 0 ) const;
  86.  
  87.         QString text() const;
  88.         QFont font() const;
  89.         bool isRichText() const;
  90.         
  91.  
  92.     protected:
  93.         bool _isRichText;
  94.         QSimpleRichText* _richText; // used when _isRichText == true
  95.         QString _text; // used when _isRichText == false
  96.         QFont _font; // used when _isRichText == false
  97.         QFontMetrics* _metrics;
  98.         bool _dirtyMetrics;
  99. };
  100.  
  101. #endif
  102.